package com.vincent.kdp.js;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.webkit.JavascriptInterface;

import com.vincent.baseapp.util.SPUtil;
import com.vincent.kdp.util.BaseParam;

public class ConnnectUhfOperator {

    private Activity context;

    public ConnnectUhfOperator(Activity context) {
        this.context = context;
    }

    @JavascriptInterface
    public String getDeviceId(){
        return BaseParam.getDeviceId();
    }

    @JavascriptInterface
    public void saveUhf(String ip){
        SPUtil.put("UHF_IP",ip);
        context.finish();
    }

    /**
     * 弹出消息对话框
     */
    @JavascriptInterface
    public void showDialog(String message) {

        Builder builder = new Builder(context);
        builder.setMessage(message);  
        builder.setTitle("提示");  
        builder.setPositiveButton("确认", new OnClickListener() {
            @Override  
            public void onClick(DialogInterface dialog, int which) {
  
            }  
        });  
        builder.setNegativeButton("取消", new OnClickListener() {
            @Override  
            public void onClick(DialogInterface dialog, int which) {  
                dialog.dismiss();  
            }  
        });  
        builder.create().show();  
    }
}  